<?php 
class adminMenu_models_index extends CI_Model{

    
    public function getAdminMenu(){
    	$this->load->database();
    	$parents=$this->db->select('*')->from('admin_menu')->where(
				array(	'parent'=>0,
						'active'=>1)
		)->order_by('order','ASC')->get()->result();
		foreach ($parents as $key=>$itemParent){
			 
			$subItem=$this->db->select('*')->from('admin_menu')->where(
					array(	'parent'=>$itemParent->id,
							'active'=>1,
					)
			)->order_by('order','ASC')->get()->result();
			if(is_array($subItem))
				$parents[$key]->subMenu=$subItem;
		}
		return $parents;
    }
}